package ${package}.${moduleName}.service.impl;


import ${package}.${moduleName}.service.api.dto.${ClassName}Query;
import ${package}.${moduleName}.convertor.${ClassName}Convertor;
import ${package}.${moduleName}.entity.${ClassName};
import ${package}.${moduleName}.respository.${ClassName}Repository;
import ${package}.${moduleName}.service.${ClassName}Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import javax.annotation.Resource;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;



/**
 * ${tableComment}
 *
 * @author ${author}
 * @since ${date}
 */
@ExtendWith(MockitoExtension.class)
class ${ClassName}ServiceImplTest {

    @Resource
    private ${ClassName}Service ${className}Service ;
    @Mock
    private ${ClassName}Convertor ${className}Convertor;
    @Mock
    private ${ClassName}Repository ${className}Repository;
    @BeforeEach
    void setUp() {
    ${className}Service=new ${ClassName}ServiceImpl( ${className}Repository,${className}Convertor);
    }
    @Test
    void page() {
        given(${className}Repository.page(any())).willReturn(new Page<>());
        ${className}Service.page(new ${ClassName}Query());
        verify(${className}Convertor, times(1)).convertToDtoList(any());
    }
    
    @Test
    void get${ClassName}ById() {
        given(${className}Repository.get${ClassName}ById(any())).willReturn(new ${ClassName}());
        ${className}Service.get${ClassName}ById(any());
        verify(${className}Convertor, times(1)).convertToDto(any());
    }
    
    @Test
    void save${ClassName}() {
        ${className}Service.save${ClassName}(any());
        verify(${className}Convertor, times(1)).convertToEntity(any());
    }
    
    @Test
    void update${ClassName}() {
        ${className}Service.update${ClassName}(any());
        verify(${className}Convertor, times(1)).convertToEntity(any());
    }
    
    @Test
    void deleteByIds() {
        ${className}Service.deleteByIds(anyList());
        verify(${className}Repository, times(1)).deleteByIds(any());
    }

}